package com.atguigu.petstore.coupon.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Data;

/**
 * 优惠 - 优惠券领取记录
 * @TableName coupon_receive
 */
@TableName(value ="coupon_receive")
@Data
public class CouponReceive implements Serializable {
    /**
     * 自动增加ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 买家ID
     */
    @TableField(value = "buyer_id")
    private Long buyerId;

    /**
     * 优惠券编号
     */
    @TableField(value = "coupon_id")
    private Long couponId;

    /**
     * 优惠券内容（具体劵的完整json数据）
     */
    @TableField(value = "coupon_content")
    private String couponContent;

    /**
     * 状态，1为已使用，0为已领取未使用，-1为已过期
     */
    @TableField(value = "status")
    private Integer status;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        CouponReceive other = (CouponReceive) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getBuyerId() == null ? other.getBuyerId() == null : this.getBuyerId().equals(other.getBuyerId()))
            && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
            && (this.getCouponContent() == null ? other.getCouponContent() == null : this.getCouponContent().equals(other.getCouponContent()))
            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getBuyerId() == null) ? 0 : getBuyerId().hashCode());
        result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
        result = prime * result + ((getCouponContent() == null) ? 0 : getCouponContent().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", buyerId=").append(buyerId);
        sb.append(", couponId=").append(couponId);
        sb.append(", couponContent=").append(couponContent);
        sb.append(", status=").append(status);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}